package 其他问题;

import java.util.HashSet;
import java.util.Scanner;

public class Main {
	
	
	public static class Node{
        private static String data;
        private static Node next;

        Node(){}
        Node(String data){
            this.data = data;
            this.next = null;
        }
    }

    public static boolean existLoop(Node node){
        Node slow = Node.next;
        Node fast = Node.next.next;

        if(slow == null || fast ==null){
            return false;
        }
        while(slow.next != null){
            if(fast.next == null){
                return false;
            }
            if(slow.data == fast.data){
                return true;
            }
            slow = slow.next;
            fast = fast.next.next;
            if(fast == null){
                return false;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] split = line.split(",");
        Node head = null;
        Node node = new Node(split[0]);
        head = node;
        for (int i = 1; i <split.length ; i++) {
            node.next = new Node(split[i]);
        }
        boolean existLoop = existLoop(head);
        System.out.println(existLoop);
    }

}
